package com.future.direction.ui.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.future.direction.R;
import com.future.direction.data.bean.CourseCatalogueBean;

import java.util.List;

public class CourseCatalogueAdapter extends BaseQuickAdapter<CourseCatalogueBean, BaseViewHolder> {
    private int selectPosition;

    public int getSelectPosition() {
        return selectPosition;
    }

    public void setSelectPosition(int selectPosition) {
        this.selectPosition = selectPosition;
        notifyDataSetChanged();
    }

    public CourseCatalogueAdapter(int layoutResId, @Nullable List<CourseCatalogueBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CourseCatalogueBean item) {
        helper.setText(R.id.tv_title,item.getTitle());
        helper.setText(R.id.tv_duration,item.getTime());
        if (item.isStudy()){
            helper.setText(R.id.tv_isStudy,"已学习");
        }else {
            helper.setText(R.id.tv_isStudy,"未学习");
        }
        if (selectPosition == helper.getLayoutPosition()){
            helper.setTextColor(R.id.tv_title,mContext.getResources().getColor(R.color.colorBlack181823));
            helper.setTextColor(R.id.tv_duration,mContext.getResources().getColor(R.color.colorYellowF6C324));
            helper.setTextColor(R.id.tv_isStudy,mContext.getResources().getColor(R.color.colorYellowF6C324));
        }else {
            helper.setTextColor(R.id.tv_title,mContext.getResources().getColor(R.color.colorBlackA6AEB7));
            helper.setTextColor(R.id.tv_duration,mContext.getResources().getColor(R.color.colorBlackA6AEB7));
            helper.setTextColor(R.id.tv_isStudy,mContext.getResources().getColor(R.color.colorBlackA6AEB7));
        }
    }
}
